package com.kingsoft.dc.khaos.extender.meta.impl;

import com.alibaba.fastjson.JSON;
import com.kingsoft.dc.khaos.extender.meta.model.ds.Connect;
import com.kingsoft.dc.khaos.extender.meta.model.ds.Ks3Connect;
import com.kingsoft.dc.khaos.extender.meta.utils.RSAEncrypt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by haorenhui on 2020/01/17
 */
public class Ks3DmMetaImpl extends DmMetaImpl  {

    private static Logger logger = LoggerFactory.getLogger(Ks3DmMetaImpl.class);

    @Override
    public Connect decryptDatasourceConnectSecret(String config) {
        Ks3Connect connect = JSON.parseObject(config, Ks3Connect.class);
        try {
            connect.setAccessKeySecret(RSAEncrypt.decryptByRSAPassWord(connect.getAccessKeySecret()));
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage(),e);
        }
        return connect;
    }
}
